package com.itheima.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/quick")
public class QuickController {
    //第一种获取数据方式
    @Value("${name}")
    private String username;
    @Value("${person.name}")
    private String name;
    @Value("${address[0]}")
    private String address;
    @Value("${pp.name}")
    private String ppname;
    @Value("${msg1}")
    private String msg1;
    @Value("${msg2}")
    private String msg2;

    @Autowired
    private Environment env;

    @GetMapping("/index")
    public String index(){
        System.out.println("name="+name);
        System.out.println("address="+address);
        System.out.println("ppname="+ppname);
        System.out.println(msg1);
        System.out.println(msg2);

        System.out.println(env.getProperty("server.port"));
        System.out.println(env.getProperty("person.name"));
        return "大爷来玩";
    }
}
